 <script>
            $(document).ready(function(){
    
            function displayVals() {
            var etapaValues = $("#tipoM").val();
        
            if(etapaValues == 2)
            {
            	$("#error").html("<td colspan='2'><textarea rows='15' cols='100' class='body' name='body'></textarea></td>");

           	 tinyMCE.init({
     			// General options
     		    mode : "textareas",
     			theme : "advanced",
     			plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",

     			// Theme options
     			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
     			theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
     			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions	|,print,|,ltr,rtl,|,fullscreen",
     			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
     			theme_advanced_toolbar_location : "top",
     			theme_advanced_toolbar_align : "left",
     			theme_advanced_statusbar_location : "bottom",
     		

     			// Example word content CSS (should be your site CSS) this one removes paragraph margins
     			content_css : "css/word.css",

     			// Drop lists for link/image/media/template dialogs
     			template_external_list_url : "lists/template_list.js",
     			external_link_list_url : "lists/link_list.js",
     			external_image_list_url : "lists/image_list.js",
     			media_external_list_url : "lists/media_list.js",

     			// Replace values for the template plugin
     			template_replace_values : {
     				username : "Some User",
     				staffid : "991234"
     			}
     		});
            }
            if(etapaValues == 1)
            {
            	$("#error").html("<td><strong>Body SMS</strong></td><td><input type='text' name='body' size='50' class='required' /></td>");
            } 
    
    }

    function displayCategoria(){
    	var etapaValues = $("#categoria").val();

           if (etapaValues == 1){
        	   $("#categoriaDiv").html("Recordarle al cliente que su servicio esta en un determinado estado o etapa."); 	 
           }else if(etapaValues == 2){  
        	   $("#categoriaDiv").html("Explicarles los plazos y las fechas a vencer para su cumplimiento."); 	 
           }else{
        	   $("#categoriaDiv").html("Ha terminado algun tipo de compromiso de nosotros o el cliente.");
           }
    	

    }        

    $("select").change(displayCategoria);
    $("select").change(displayVals);
    displayVals();
    displayCategoria();

  });
  </script>


<div id="titulo">Agregar Script</div>
<?php echo form_open_multipart('script/save', array('name' => 'estatus','id' => 'commentForm'));?>
	<table class="tablaform" width="100%" border="0">		
		<tr>
			<td><b>Title Script:</b> </td>
			<td><input type="text" name="title" class="required" id="title" maxlength="100" size="40" value="" /></td>
		</tr>

	    <tr>
			<td><b>Subject Script:</b> </td>
			<td><input type="text" name="sub" class="required" id="sub" maxlength="100" size="40" value="" /></td>
		</tr>
		
		 <tr>
			<td><b>From Script:</b> </td>
			<td>
			    <select name="from" class="required" id="from">
			       <?php 
			          foreach ($from as $k):
			              echo '<option value='.$k->getIdFrom().'>'.$k->getBody().'</option>';
			          endforeach;
			       ?>
			    </select>	
			    
			</td>
		</tr>
		
	     <tr>
			<td><b>Tipo Script:</b> </td>
			<td>
			    <select name="tipoM" class="required" id="tipoM"  onChange="tel()">
			       <option value="1">SMS</option>
			       <option value="2">Mail</option>
			    </select>			
			</td>
		</tr>
		
		
		
		 <tr>
			<td><b>Departamentos:</b> </td>
			<td>
			    <select name="departamentos" class="required" id="departamentos">
			         <?php 
			            foreach ($departamentos as $k):
			                echo '<option value='.$k->getIdEstatus().'>'.$k->getNombre().'</option>';
			            endforeach;
			          ?>
			    </select>				
			</td>
		</tr>
		
		 <tr>
			<td><b>Categoria Script:</b> </td>
			<td>
			    <select name="categoria" class="required" id="categoria">
			        <?php 
			            foreach ($categoria as $k):
			                echo '<option value='.$k->getIdCategoria().'>'.$k->getCategoria().'</option>';
			            endforeach;
			          ?>
			    </select>	
			    <font id="categoriaDiv" style="color:#0000FF"></font>				
			</td>
		</tr>
				
				  <tr id="error">
        
       </tr>
     	<tr><td colspan="2"><hr /></td></tr>
		<tr><td><input type="submit" value="Guardar" /></td>
		 <td><a href="<?php echo site_url().'/script' ?>"><input type="button" value="Atras" align="center"/></a></td>
		</tr>
	</table>
</form>